Hello and welcome.
In this video we will start creating the javascript logic that will enable the come down time to work.
Let's begin with some javascript basics.
What are methods methods are basically actions that can be performed on an object saw objects.
Objects are basically containers for named valli's.
For example a car can be an object a person can be an object set interval method the set into for metod
basically is used when you want to set intervals.
So it is used to call function at a specified intervals is usually in milliseconds so for example 1000
milliseconds it would be equivalent to one second.
So if you are great in a time and you want the time out or a clock tick every second you use this set
interval method.
So if thousand milliseconds is equivalent to one second we are also going to be using javascript date
method did met us busy.
We use to set and get data values using the javascript statement.
It will allow you to set various dates and values so you can set it in the year the month the day the
hours the minutes the seconds or saw in me.
Javascript also comes with a built in maths method.
One of the methods is called maths floor.
This basically allows you to round numbers down once to the nearest integer.
For example if you got a value of five point three rounded down to five.
So quoting how a javascript logic for our projects will be used in methods will be referenced in objects
will be used in the set of a method as well as Date met.
Also maths top floor method.
So I've got my text editor.
I am going to create a javascript file so we click on the file here and I'm going to save ants and that
should take me to my directory.
So I am going to keep it in name of Count down.
G s so I'll save it in the same directory.
Just click on say.
So far now is a javascript file.
Now that we've created the javascript file the first thing I want to do is set the date that we are
going to count to.
You can choose any date for me.
I'm going to come down to January 1st 2000 and 10 12 mid day so when I need to do I create a variable
and give the variable in name.
When you're creating variables is good to name your variables to reflect what the store.
So I'm going to create a variable called Count Down date and I'm going to use the date motor out and
I'll be referencing a new date inside B parameters for the method.
I'm going to pass them.
The value of January 1st 2009 18 also all time and seconds and I'll be using the get time method.
So here I've created a variable called Countdown date and I've said that to you close to his new date
and he never did.
Fear values inside this parenthesis here because I want to come down to January 1st 2000 any team at
45 12:00 now so does the hours the minutes and the seconds and I'm using the get time method which is a
date method.
Next one I do want to update make count down every one second so I am going to create another variable.
And I'm going to also set it to of course of this set of function set for intervals.
Be what you use use a set of metal to indicate the intervals you want to set.
So I've created another variable and have called it variable variable x.
And I've said that too cause so this set interval method.
And inside the parentheses are passed to the function with a function you horswell me to have curly
braces in between the calibrated is where I will had all the logic for the code that when they were
the countdown time I had to work.
So I'm going to tab down to separate the calibrators and every cause I write in between this curly process
is what will constitute the logic that will make it come down time to work.
So next I want to create a variable that will get today's date and time.
So I've created a variable chord now to indicate the current date and I've said it to cause a new date
and nothing.
Brand It is and I've used the get time method what this will do.
It will return to D date and time.
Next thing I want to do is find the distance between this variable which is today's date and this variable
here which is the count that date someone equating a variable called distance and I'm going to stop
pracht this countdown date from the current date time which is some support in this variable from this
variable and that will give me the distance between today's date and my count down.
So I created another variable called distance and set that to Quantico the countdown date which is variable
here.
Mine is now which is variable here so this now reference the current date and time this count down their
references date here which is a data counting down to the distance.
Surprised that from this current date and that will tell us how much time we have left.
So I'm going to end the part one of the javascript logic here in part 2 we will be doing the time calculations
for the days hours minutes and the sequence.
Thanks for watching.
Bye for now.